package httpplay;
import java.io.IOException;
import java.nio.charset.Charset;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;


/**
 * @author Han
 */
public class ReadBook {
	public static void main(String[] args) throws ClientProtocolException, IOException {
		HttpClient client =HttpClients.createDefault();
		HttpGet get = new HttpGet("http://www.kanunu8.com/wuxia/201102/1621/36920.html");
		HttpResponse response = client.execute(get);
		String content = EntityUtils.toString(response.getEntity(),Charset.forName("gbk"));
		content = content.substring(content.indexOf("<p>")+3,content.indexOf("</p>"));
		content = content.replaceAll("&nbsp;", "");
		content = content.replaceAll("<br />", "");
		writeline(content);
	}
	public static void writeline(String line){
		if(line.length()>=60){
			System.out.println(line.substring(0,60));
			System.out.println("");
			writeline(line.substring(60,line.length()));
		}else{
			System.out.println(line);
			System.out.println();
		}
	}
}
